#pragma once #define _USE_MATH_DEFINES #include namespace PomocSoczewka { ... ... #pragma endregion double X,F,Hp; static double Xp=-10.0, Xk=10.0, Yp=-10.0, Yk=10.0; int ex( double x) { return int((x-Xp)/(Xk-Xp)*pictureBox1->Width); } int ey( double y) { return int((Yk-y)/(Yk-Yp)*pictureBox1->Height); } //--------------------------------------------------------------------------- private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) { X=-5.0; Hp=5.25; F=3.15; } //--------------------------------------------------------------------------- private: System::Void hScrollBar_Scroll(System::Object^ sender, System::Windows::Forms::ScrollEventArgs^ e) { X =0.01*hScrollBarX->Value; textBoxX->Text=X.ToString("F2"); Hp=0.01*hScrollBarH->Value; textBoxH->Text=Hp.ToString("F2"); F =0.01*hScrollBarF->Value; textBoxF->Text=F.ToString("F2"); pictureBox1->Invalidate(); } //--------------------------------------------------------------------------- private: System::Void pictureBox1_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) { Graphics^ grafika = e->Graphics; grafika->Clear( Color::White); Pen^ pioro=gcnew Pen(System::Drawing::Color::Black); grafika->DrawLine(pioro, ex(Xp),ey(0.0),ex(Xk),ey(0.0)); grafika->DrawEllipse(pioro, ex( F)-3, ey(0.0)-3, 6, 6); grafika->DrawLine(pioro, ex(X),ey(0.0),ex( X),ey(Hp)); } //--------------------------------------------------------------------------- private: System::Void pictureBox1_Resize(System::Object^ sender, System::EventArgs^ e) { pictureBox1->Invalidate(); } //--------------------------------------------------------------------------- }; }